home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DDJMAG / DDJ9203.ZIP / OOPASM.ZIP / MENUBAR.ASM < prev    next >
Assembly Source File  |  1994-03-04  |  3KB  |  142 lines

  1.     .MODEL    SMALL
  2.  
  3.     INCLUDE    equates.inc
  4.     INCLUDE    instance.inc
  5.     INCLUDE    messages.inc
  6.     INCLUDE    objects.inc
  7.  
  8.     UR    EQU    0            ;Upper row
  9.     LC    EQU    0            ;Left column
  10.     LR    EQU    0            ;Lower row
  11.     RC    EQU    79            ;Right column
  12.  
  13. IF1
  14.     INCLUDE    macros.mac
  15.     INCLUDE    objects.mac
  16. ENDIF
  17.  
  18.     EXTRN    readEvent:NEAR
  19.     EXTRN    sendMsg:NEAR
  20.  
  21.     EXTRN    Dispatch:WORD
  22.     EXTRN    Hardware:WORD
  23.     EXTRN    Help:WORD
  24.     EXTRN    HorzMenu:WORD
  25.     EXTRN    Mouse:WORD
  26.     EXTRN    Self:WORD
  27.     EXTRN    System:WORD
  28.     EXTRN    VertMenu0:WORD
  29.     EXTRN    VertMenu1:WORD
  30.     EXTRN    VertMenu2:WORD
  31.     EXTRN    VertMenu3:WORD
  32.  
  33.     .CODE
  34.  
  35. IF Dbug
  36.     PUBLIC    initExecLoop
  37. ENDIF
  38. COMMENT    %
  39. ==============================================================================
  40. If no other context is active starts-up executive loop.
  41.  
  42. =============================================================================%
  43. initExecLoop    PROC    NEAR
  44.     getInst        ax,NextContext,Dispatch    ;Get next read context
  45.     identity    ax,iel1            ;Is there one? - Exit
  46.     send        MenuBar,Read        ;Enter executive loop
  47. iel1:    ret
  48. initExecLoop    ENDP
  49.  
  50.  
  51.  
  52.     PUBLIC    clrNextContext
  53. COMMENT    %
  54. ==============================================================================
  55. Makes the next dispatcher object the top-level executive.
  56.  
  57. =============================================================================%
  58. clrNextContext    PROC    NEAR
  59.     lea        ax,MenuBar        ;Get top-level object
  60.     setInst        NextContext,ax,Dispatch    ;Set it as next context
  61.     ret
  62. clrNextContext    ENDP
  63.  
  64.  
  65.  
  66. COMMENT    %
  67. ==============================================================================
  68. Selects the appropriate menu item based on mouse location.
  69.  
  70. =============================================================================%
  71. selectItem    PROC    NEAR
  72.     getInst        bl,Col1,Mouse        ;Get mouse column
  73.     moreThan    bl,LC+45,sli2        ;Exit if > MC+35
  74.     xor        ax,ax            ;Select 1st item 
  75.     lessThan    bl,LC+9,sli1        ;Done if < MC+9
  76.     mov        ax,1*MenuEntrySize    ;Select 2nd item 
  77.     lessThan    bl,LC+17,sli1        ;Done if < MC+17
  78.     mov        ax,2*MenuEntrySize    ;Select 3rd item 
  79.     lessThan    bl,LC+25,sli1        ;Done if < MC+25
  80.     mov        ax,3*MenuEntrySize    ;Select 4th item 
  81.  
  82. sli1:    send        Self,Hilite,ax        ;Hilite menubar item
  83.     send        Self,Select        ;Select menu item
  84. sli2:    ret
  85. selectItem    ENDP
  86.  
  87.  
  88.  
  89.     .DATA
  90.  
  91. defMenu        MenuBar,\
  92.     <" File "," Edit "," View "," Special ">
  93.  
  94. defMenuTbl    MenuBar,\
  95.     <VertMenu0,Refresh,VertMenu0,Read>,\
  96.     <VertMenu1,Refresh,VertMenu1,Read>,\
  97.     <VertMenu2,Refresh,VertMenu2,Read>,\
  98.     <VertMenu3,Refresh,VertMenu3,Read>
  99.  
  100. defDispTbl    MenuBar,\
  101.     <0,0,3,0,0,0,0,System,Reset>,\
  102.     <0,75,3,0,0,0,0,Self,Prev>,\
  103.     <0,77,3,0,0,0,0,Self,Next>,\
  104.     <13,28,3,0,0,0,0,Self,Select>,\
  105.     <27,1,3,0,0,0,0,System,Refresh,System,Read>,\
  106.     <0,68,3,0,0,0,0,System,Refresh,System,Read>,\
  107.     <0,Nil,1,UR,LC+1,UR,LC+45,Self,Drag>,\
  108.     <0,Nil,1,2,70,22,79,Help,Click>,\
  109.     <Nil,Nil,Nil,0,0,24,79,Hardware,Refresh>
  110.  
  111. defMsg    MenuBar,\
  112.     Init,\
  113.     <,,initExecLoop>
  114.  
  115. defMsg    MenuBar,\
  116.     Read,\
  117.     <,,readEvent>
  118.  
  119. defMsg    MenuBar,\
  120.     Drag,\
  121.     <,,selectItem>
  122.  
  123. defObj    MenuBar,\
  124.     <HorzMenu>,\
  125.     <Row1,1,UR,\
  126.     Col1,1,LC,\
  127.     Row2,1,LR,\
  128.     Col2,1,RC,\
  129.     Color,1,30h,\
  130.     Unused,1,Nil,\
  131.     TxtPtr,2,Nil,\
  132.     InxPtr,2,0,\
  133.     MasterObj,2,Nil,\
  134.     DispTbl,2,MenuBarDispTbl,\
  135.     MenuPtr,2,MenuBarMenu,\
  136.     MenuTbl,2,MenuBarMenuTbl>,\
  137.     <Refresh,Read,Next,Prev,Select,Init,Hilite,Drag,SelectNext,SelectPrev>
  138.  
  139.  
  140.  
  141.     END
  142.